//
//  NetworkManager+extension.swift
//  CopyWB
//
//  Created by 翁胜琼 on 2017/6/22.
//  Copyright © 2017年 iimac. All rights reserved.
//


// 封装新浪微博网络请求方法
extension NetworkManager{
    
    /// 加载微博数据字典数组
    ///
    /// - Parameter completion: status 字典数组
    func statuesList(completion : @escaping((_ statusList : [[String : AnyObject]]? , _ isSuccessed : Bool)->()) ){
        
        let urlString = "https://api.weibo.com/2/statuses/home_timeline.json"
        let params = ["access_token":"2.00rOP24CJqmc2D6095912a27pvwxeD"]
        
        request(urlString: urlString, parameters: params) { (json, isSuccessed) in
            
            // 从 json 中获取 statuses 字典数组
            // 如果 as?  失败 ， result 为 nil
            let result = (json as AnyObject)["statuses"] as? [[String : AnyObject]]
            
            completion(result, isSuccessed)
        }
    }
    
}
